package com.jsy.mini12306.order.controller;

import com.jsy.mini12306.common.entity.TicketOrder;
import com.jsy.mini12306.order.service.TicketOrderQueryService;
import com.jsy.mini12306.order.vo.TicketOrderVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 列车票订单(TicketOrder)表控制层
 *
 * @author: SongyangJi
 * @since: 2021-09-02 21:22:26
 * @description:
 */

@Slf4j
@RestController
@RequestMapping("ticketOrder")
public class TicketOrderController {


    @Resource
    TicketOrderQueryService ticketOrderQueryService;

    @GetMapping("/history/{buyerId}")
    public ResponseEntity<List<TicketOrderVO>> getHistoryOrders(@PathVariable Long buyerId) {
        return ResponseEntity.ok(ticketOrderQueryService.getHistoriesByBuyerId(buyerId));
    }

    @GetMapping("/unused/{buyerId}")
    public ResponseEntity<List<TicketOrderVO>> getUnusedOrders(@PathVariable Long buyerId) {
        return ResponseEntity.ok(ticketOrderQueryService.getUnusedByBuyerId(buyerId));
    }

}
